dataviz\figure\datasets/
scattergraphdataset.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use crate::figure::utilities::scatterdottype::ScatterDotType;

/// A dataset for scatter graphs, representing points and their appearance.
pub struct ScatterGraphDataset {
    /// A collection of `(x, y)` data points for the scatter graph.
    pub points: Vec<(f64, f64)>,
    /// Color of the scatter points in RGB format.
    pub color: [u8; 3],
    /// Label for the dataset, used in legends or annotations.
    pub label: String,
    /// Shape of the scatter points (circle, square, triangle, etc.).
    pub dot_type: ScatterDotType,
}

impl ScatterGraphDataset {
    /// Creates a new `ScatterGraphDataset` instance with the specified appearance and metadata.
    ///
    /// # Parameters
    /// - `color`: The RGB color of the scatter points.
    /// - `label`: A descriptive label for the dataset.
    /// - `dot_type`: The shape of the scatter points (`ScatterDotType`).
    ///
    /// # Returns
    /// A new `ScatterGraphDataset` instance with an empty list of points.
    ///
    /// # Example
    /// ```rust
    /// use crate::figure::utilities::scatterdottype::ScatterDotType;
    ///
    /// let dataset = ScatterGraphDataset::new(
    ///     [255, 0, 0],
    ///     "Example Dataset",
    ///     ScatterDotType::Circle(5)
    /// );
    /// ```
    pub fn new(color: [u8; 3], label: &str, dot_type: ScatterDotType) -> Self {
        Self {
            points: Vec::new(),
            color,
            label: label.to_string(),
            dot_type,
        }
    }
}